<html>
  <head>
    <title>S.M.A.R.T detail of <%=dev%></title>
    <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
    <script type="text/javascript" src="<%=resource%>/xhr.js"></script>

    <script type="text/javascript">//<![CDATA[

      XHR.get('<%=luci.dispatcher.build_url("admin", "nas", "smartinfo", "smartattr", dev)%>', null,
        function(x, st)
        {
          var tb = document.getElementById('smart_attr_table');
          if (st && tb)
          {
            /* clear all rows */
            while( tb.rows.length > 1 )
              tb.deleteRow(1);

            for( var i = 0; i < st.length; i++ )
            {
              var tr = tb.insertRow(-1);
                tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
              var td = null
          
              tr.insertCell(-1).innerHTML = st[i].id;
              tr.insertCell(-1).innerHTML = st[i].attrbute;
              tr.insertCell(-1).innerHTML = st[i].flag;
              tr.insertCell(-1).innerHTML = st[i].value;
              tr.insertCell(-1).innerHTML = st[i].worst;
              tr.insertCell(-1).innerHTML = st[i].thresh;
              tr.insertCell(-1).innerHTML = st[i].type;
              tr.insertCell(-1).innerHTML = st[i].updated;
              tr.insertCell(-1).innerHTML = st[i].raw;
              
              if( ( st[i].id == '05' || st[i].id == 'C5' ) && st[i].raw != '0' )
              {
                tr.style.cssText = "background-color:red !important;";
              }

            }

            if( tb.rows.length == 1 )
            {
              var tr = tb.insertRow(-1);
              tr.className = 'cbi-section-table-row';

              var td = tr.insertCell(-1);
              td.colSpan = 4;
              td.innerHTML = '<em><br /><%:No Attrbute to display.%></em>';
            }
          }
        }
      );
    //]]></script>

  </head>
  <body>
    <div id="maincontainer">
      <div id="maincontent">
        <fieldset class="cbi-section">
          <legend><%:S.M.A.R.T Attrbutes%>: /dev/<%=dev%></legend>
          <table class="cbi-section-table" id="smart_attr_table">
            <tr class="cbi-section-table-titles">
              <th class="cbi-section-table-cell"><%:ID%></th>
              <th class="cbi-section-table-cell"><%:Attrbute%></th>
              <th class="cbi-section-table-cell"><%:Flag%></th>
              <th class="cbi-section-table-cell"><%:Value%></th>
              <th class="cbi-section-table-cell"><%:Worst%></th>
              <th class="cbi-section-table-cell"><%:Thresh%></th>
              <th class="cbi-section-table-cell"><%:Type%></th>
              <th class="cbi-section-table-cell"><%:Updated%></th>
              <th class="cbi-section-table-cell"><%:Raw%></th>
            </tr>
            <tr class="cbi-section-table-row">
              <td colspan="4"><em><br /><%:Collecting data...%></em></td>
            </tr>
          </table>
        </fieldset>
      </div>
    </div>
  </body>
</html>